home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / msgbox / msgedit.frm < prev   
Text File  |  1995-05-08  |  9KB  |  284 lines

  1. VERSION 2.00
  2. Begin Form MsgEdit 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "MsgBox Editor"
  5.    ClientHeight    =   4155
  6.    ClientLeft      =   1605
  7.    ClientTop       =   1965
  8.    ClientWidth     =   5550
  9.    ForeColor       =   &H00000000&
  10.    Height          =   4845
  11.    Left            =   1545
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   4155
  17.    ScaleWidth      =   5550
  18.    Top             =   1335
  19.    Width           =   5670
  20.    Begin CommandButton Finished 
  21.       Caption         =   "&Finished!"
  22.       FontBold        =   -1  'True
  23.       FontItalic      =   0   'False
  24.       FontName        =   "MS Sans Serif"
  25.       FontSize        =   12
  26.       FontStrikethru  =   0   'False
  27.       FontUnderline   =   0   'False
  28.       Height          =   495
  29.       Left            =   1920
  30.       TabIndex        =   6
  31.       Top             =   3480
  32.       Width           =   1815
  33.    End
  34.    Begin CommandButton MessageClear 
  35.       Caption         =   "Clear"
  36.       Height          =   495
  37.       Left            =   4680
  38.       TabIndex        =   5
  39.       Top             =   2640
  40.       Width           =   615
  41.    End
  42.    Begin CommandButton MessageOK 
  43.       Caption         =   "OK"
  44.       Height          =   495
  45.       Left            =   4680
  46.       TabIndex        =   4
  47.       Top             =   2040
  48.       Width           =   615
  49.    End
  50.    Begin TextBox MessageEdit 
  51.       Height          =   855
  52.       Left            =   240
  53.       MultiLine       =   -1  'True
  54.       TabIndex        =   3
  55.       Top             =   2040
  56.       Width           =   4215
  57.    End
  58.    Begin CommandButton TitleClear 
  59.       Caption         =   "Clear"
  60.       Height          =   495
  61.       Left            =   4680
  62.       TabIndex        =   2
  63.       Top             =   1200
  64.       Width           =   615
  65.    End
  66.    Begin CommandButton TitleOK 
  67.       Caption         =   "OK"
  68.       Height          =   495
  69.       Left            =   4680
  70.       TabIndex        =   1
  71.       Top             =   600
  72.       Width           =   615
  73.    End
  74.    Begin TextBox TitleEdit 
  75.       Height          =   375
  76.       Left            =   240
  77.       TabIndex        =   0
  78.       Top             =   600
  79.       Width           =   4215
  80.    End
  81.    Begin Label Label3 
  82.       Caption         =   "Use Return to start new line, and Control-Return (or click on OK) to accept text."
  83.       FontBold        =   0   'False
  84.       FontItalic      =   0   'False
  85.       FontName        =   "MS Sans Serif"
  86.       FontSize        =   8.25
  87.       FontStrikethru  =   0   'False
  88.       FontUnderline   =   0   'False
  89.       Height          =   375
  90.       Index           =   1
  91.       Left            =   240
  92.       TabIndex        =   10
  93.       Top             =   3000
  94.       Width           =   4215
  95.    End
  96.    Begin Label Label1 
  97.       Caption         =   "Enter MsgBox &Message Here:"
  98.       FontBold        =   -1  'True
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   12
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   0   'False
  104.       Height          =   375
  105.       Left            =   360
  106.       TabIndex        =   7
  107.       Top             =   1560
  108.       Width           =   3855
  109.    End
  110.    Begin Label Label3 
  111.       Caption         =   "Use Control-Return (or click on OK) to accept text."
  112.       FontBold        =   0   'False
  113.       FontItalic      =   0   'False
  114.       FontName        =   "MS Sans Serif"
  115.       FontSize        =   8.25
  116.       FontStrikethru  =   0   'False
  117.       FontUnderline   =   0   'False
  118.       Height          =   255
  119.       Index           =   0
  120.       Left            =   240
  121.       TabIndex        =   9
  122.       Top             =   1080
  123.       Width           =   4215
  124.    End
  125.    Begin Label Label2 
  126.       Caption         =   "Enter MsgBox &Title Here:"
  127.       FontBold        =   -1  'True
  128.       FontItalic      =   0   'False
  129.       FontName        =   "MS Sans Serif"
  130.       FontSize        =   12
  131.       FontStrikethru  =   0   'False
  132.       FontUnderline   =   0   'False
  133.       ForeColor       =   &H00000000&
  134.       Height          =   375
  135.       Left            =   360
  136.       TabIndex        =   8
  137.       Top             =   120
  138.       Width           =   4095
  139.    End
  140.    Begin Menu Hints 
  141.       Caption         =   "&Hints"
  142.       Begin Menu TitleMsg 
  143.          Caption         =   "&Title..."
  144.       End
  145.       Begin Menu MsgMsg 
  146.          Caption         =   "&Message..."
  147.       End
  148.       Begin Menu EditMsg 
  149.          Caption         =   "&Editing..."
  150.       End
  151.       Begin Menu sep 
  152.          Caption         =   "-"
  153.       End
  154.       Begin Menu AboutMsg 
  155.          Caption         =   "&About..."
  156.       End
  157.    End
  158. End
  159.  
  160. Sub AboutMsg_Click ()
  161.     MBAbout.Show
  162. End Sub
  163.  
  164. Function CheckString (TheText As String, TheType As Integer)
  165.     CheckString = True
  166.     StrMsg$ = "VB will will truncate this long word at the 255th character.  Try again!"
  167.     LenMsg$ = "VB will only allow 1,024 characters in a message box.  Try again!"
  168.     WordText$ = TheText
  169.     While InStr(WordText$, Chr$(32)) > 0
  170.     If InStr(WordText$, Chr$(32)) > 255 Then
  171.         MsgBox StrMsg$, 16, "String Error"
  172.         CheckString = False
  173.     End If
  174.     WordText$ = Mid$(WordText$, InStr(WordText$, Chr$(32)) + 1)
  175.     Wend
  176.     If Len(TheText) > 1024 And TheType = MSG Then
  177.     MsgBox LenMsg$, 16, "String Error"
  178.     CheckString = False
  179.     End If
  180. End Function
  181.  
  182. Sub EditMsg_Click ()
  183.     CR$ = Chr$(13) + Chr$(10)
  184.     Q$ = Chr$(34)
  185.     TheMessage$ = "Instructions for editing are placed below the edit boxes.  You may embed carriage returns"
  186.     TheMessage$ = TheMessage$ + " in the Message section by pressing Return.  You can accept the text by pressing Control-Return in either the Title or"
  187.     TheMessage$ = TheMessage$ + " the Message Box. You may also use a mouse to click on the OK buttons and the Finished button."
  188.     TheStyle = 0
  189.     TheTitle$ = "Editing"
  190.     MsgBox TheMessage, TheStyle, TheTitle
  191. End Sub
  192.  
  193. Sub Finished_Click ()
  194.     If Len(RawMessage) > 0 Then
  195.     MsgEdit.Hide
  196.     MsgBxGen.Show
  197.     MsgBxGen.CopyCtl.SetFocus
  198.     Else
  199.     AnAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  200.     If AnAnser = RETRY Then
  201.         Exit Sub
  202.     Else
  203.         End
  204.     End If
  205.     End If
  206. End Sub
  207.  
  208. Sub MessageClear_Click ()
  209.     MessageEdit.Text = ""
  210. End Sub
  211.  
  212. Sub MessageEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  213.     CtrlDown% = (Shift And CTRL_MASK) > 0
  214.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  215.     If CtrlDown% Then
  216.         StringState = CheckString((MessageEdit.Text), MSG)
  217.         If StringState <> False Then
  218.         RawMessage = Left$(MessageEdit.Text, Len(MessageEdit.Text) - 2)
  219.         End If
  220.         If Len(RawMessage) > 0 Then
  221.         Finished.SetFocus
  222.         Else
  223.         AnAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  224.         If AnAnser = RETRY Then
  225.             Exit Sub
  226.         Else
  227.             End
  228.         End If
  229.         End If
  230.     End If
  231.     End If
  232.  
  233. End Sub
  234.  
  235. Sub MessageOK_Click ()
  236.     StringState = CheckString((MessageEdit.Text), MSG)
  237.     If StringState <> False Then
  238.     RawMessage = MessageEdit.Text
  239.     End If
  240.     Finished.SetFocus
  241. End Sub
  242.  
  243. Sub MsgMsg_Click ()
  244.     CR$ = Chr$(13) + Chr$(10)
  245.     Q$ = Chr$(34)
  246.     TheMessage$ = "The message box function/procedure will only accept messages 1,024 characters"
  247.     TheMessage$ = TheMessage$ + " long.  Longer messages will be truncated at the 1,024th character.  Words (any series of characters without intervening spaces) will be truncated at the 255th character."
  248.     TheStyle = 0
  249.     TheTitle$ = "The Message"
  250.     MsgBox TheMessage, TheStyle, TheTitle
  251. End Sub
  252.  
  253. Sub TitleClear_Click ()
  254.     TitleEdit.Text = ""
  255. End Sub
  256.  
  257. Sub TitleEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  258.     CtrlDown% = (Shift And CTRL_MASK) > 0
  259.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  260.     If CtrlDown% Then
  261.         TheTitle = TitleEdit.Text
  262.         MessageEdit.SetFocus
  263.     End If
  264.     End If
  265. End Sub